package de.android.data;

import java.io.*;
import java.util.HashMap;

import android.app.Activity;

public class Readin extends Activity{
	
	private BufferedReader stdin = null;
	private HashMap<String,String> map = null;
	
	public Readin(){}
	
	public Readin(File file) throws FileNotFoundException{
		String line = "";
		stdin = new BufferedReader(
				new InputStreamReader(new FileInputStream(file)));
		try {
			while((line=stdin.readLine()) != null){
				String line2 = stdin.readLine();
				if(isQ(line) && isA(line2)){
					line = doSplit(line);
					line2 = doSplit(line2);
					map.put(line, line2);
				} else {
					continue;
				}
					
			}
		} catch (IOException e) {e.printStackTrace();}
		
	}
	private String doSplit(String line){
		String[] arr = line.split(":");
		return arr[1];
	}
	private boolean isQ(String line){
		if(line.startsWith("Frage"))
			return true;
		else
			return false;
	}
	private boolean isA(String line){
		if(line.startsWith("Antwort"))
			return true;
		else
			return false;
	}

	public HashMap<String, String> getMap() {
		return map;
	}

}
